
#pragma once

#include "Input.h"

#define	ButtonPressed(state) ((state&0x80)?1:0)
#define	ButtonDown(state,last) (((state^last))&state)
#define	ButtonUp(state,last) (((state^last))&last)

class CDirectInput;

class CDirectInputDevice
{
public:

	friend BOOL CALLBACK DIEnumDeviceObjects(LPCDIDEVICEOBJECTINSTANCE lpddoi,LPVOID pvRef);
	
	CDirectInputDevice();
	~CDirectInputDevice();
	
	void Attach( CDirectInput* pDI, LPDIRECTINPUTDEVICE8 pDevice );
	void Release( );

	virtual bool Update();
	virtual bool Init( HWND hWnd );

	void SetAxisMode( BOOL bAbsAxis );
	void SetAbsAxisRange( int iAxis,int lMin,int lMax);
	void SetAbsAxisDeadzone( int iAxis,int dwValue);
	int GetObjectCount( DWORD dwType );
	bool HaveObject( DWORD dwType );

	CComPtr<IDirectInputDevice8> m_pDevice;
	std::vector<LPCDIDEVICEOBJECTINSTANCE> devObjInst;
	CDirectInput* m_pDirectInput;
	HWND m_hWnd;
};
